{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">
                        <div class="layui-input-inline layui-form">
                            <select name="tuitype" id="tuitype" lay-search="" class="layui-input">
                                <option value="">全部类型</option>
                                <option value="1">换货</option>
                                <option value="2">退货</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="contract" id="contract" lay-search="" class="layui-input">
                                <option value="">全部订单类型</option>
                                <option value="1">自营订单</option>
                                <option value="2">增补订单</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="type" id="n_range" lay-search="" class="layui-input">
                                <option value="">全部状态</option>
                                <option value="1">待处理</option>
                                <option value="2">售后中</option>
                                <option value="3">已完成</option>
                                <option value="4">已拒绝(已关闭)</option>
                            </select>
                        </div>

                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="n_title" style="width: 240px" class="layui-input search" name="n_title" placeholder="退货单号/快递单号/收件人/手机号"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" style="width: 90px;margin-left: 50px;" id="orderid" class="layui-input search" name="orderid" placeholder="订单id"/>
                        </div>
                        <div class="layui-input-inline" style="margin-left: 40px;">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button class="layui-btn layui-btn-normal" id="empty" lay-submit="" lay-filter="LAY-search">
                                重置
                            </button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 导出 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-print"></i> 导出汇总</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllDetail"><i class="fa fa-print"></i> 导出明细</a></li>
                        </ul>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--状态显示模板-->
                    <script type="text/html" id="type">
                        {{# if(d.type == 1){ }}
                        换货
                        {{# } }}
                        {{# if(d.type == 2){ }}
                        退货
                        {{# } }}
                    </script>
                    <!--状态显示模板-->
                    <script type="text/html" id="son">
                        {{# if(d.tui_user_son_id){ }}
                        增补订单
                        {{# } else {}}
                        自营订单
                        {{# } }}
                    </script>
                    <!--状态显示模板-->
                    <script type="text/html" id="status">
                        {{# if(d.status == 1){ }}
                        待处理
                        {{# } }}
                        {{# if(d.status == 2){ }}
                        已同意
                        {{# } }}
                        {{# if(d.status == 3){ }}
                        已拒绝
                        {{# } }}
                    </script>
                    <!--状态显示模板-->
                    <script type="text/html" id="is_send">
                        {{# if(d.status == 2){ }}
                            {{# if(d.is_send == 0){ }}
                                {{# if(d.type == 1){ }}
                                未发货
                                {{# } else {}}
                                未打款
                                {{# } }}
                            {{# } }}

                            {{# if(d.is_send == 1){ }}
                                {{# if(d.type == 1){ }}
                                已发货
                                {{# } else {}}
                                已打款
                                {{# } }}
                            {{# } }}
                        {{# } else {}}
                        无
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情', '{:url('orderInfo')}?tui_id={{d.tui_id}}')" class="btn btn-warning btn-xs m-r-xs" title="详情"><i class="fa fa-edit">详情</i></a>
                        {{# if(d.status == 1){ }}
                        <a href="javascript:;" onclick="wk.layer_show('审核', '{:url('orderYesSend')}?tui_id={{d.tui_id}}&type={{d.type}}')" class="btn btn-warning btn-xs m-r-xs" title="审核"><i class="fa fa-edit">审核</i></a>
                        {{# } }}
                        {{# if(d.fahuo == 2){ }}
                        <a href="javascript:;" onclick="wk.layer_show('快递发货', '{:url('orderSend')}?tui_id={{d.tui_id}}')" class="btn btn-warning btn-xs m-r-xs" title="快递发货"><i class="fa fa-edit">快递发货</i></a>
                        {{# } }}
                        {{# if(d.tuikuan == 2){ }}
                        <a href="javascript:;" onclick="wk.layer_show('退款', '{:url('orderTuiMoney')}?order_erp_wl_no={{d.order_erp_wl_no}}')" class="btn btn-warning btn-xs m-r-xs" title="退款"><i class="fa fa-edit">退款</i></a>
                        {{# } }}
                        {{# if(d.gai == 2){ }}
                        <a href="javascript:;" onclick="wk.layer_show('快递修改', '{:url('orderSend')}?order_erp_wl_no={{d.order_erp_wl_no}}')" class="btn btn-warning btn-xs m-r-xs" title="快递修改"><i class="fa fa-edit">快递修改</i></a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<textarea id="allidsForOut" class="hidden"></textarea>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Ordertui/index")}'
            , response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
//            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left',}
                , {type: 'numbers', width: 80, title: '序号'}
                , {field: 'order_erp_wl_no', width: '100', title: '退货单号', align: 'center'}
                , {field: 'order_id', width: '100', title: '原订单id', align: 'center'}
                , {field: 'good_name', width: '', title: '商品名字', align: 'center'}
//                , {field: 'goods_info', width: '', title: '商品规格', align: 'center'}
//                , {field: 'unit_price', width: '', title: '商品单价', align: 'center'}
                , {field: 'all_money', width: '', title: '总金额', align: 'center'}
                , {field: 'all_num', width: '', title: '总数量', align: 'center'}
                , {field: 'express', width: '', title: '快递公司', align: 'center'}
                , {field: 'express_no', width: '', title: '快递单号', align: 'center'}
                , {field: 'user_username', width: '', title: '用户昵称', align: 'center'}
                , {field: 'user_phone', width: '', title: '用户手机号', align: 'center'}
                , {field: 'created_at', width: '', title: '创建时间', align: 'center'}
                , {field: 'type', width: '', title: '售后类型', align: 'center', toolbar: '#type'}
                , {field: 'tui_user_son_id', width: '', title: '订单类型', align: 'center', toolbar: '#son'}
                , {field: 'remark', width: '', title: '售后备注', align: 'center'}
                , {field: 'status', width: '', title: '是否同意', align: 'center', toolbar: '#status'}
                , {field: 'is_send', width: '', title: '售后进度', align: 'center', toolbar: '#is_send'}
                , {fixed: 'right', width: 300, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            , done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("changeGoodStatus")}',obj);
        });
        //批量操作
        var $ = layui.$, active = {
            excelAll: function(){
                //导出Excel
                wk.excelAll('',$('.layui-input').serialize(),"{:url('excelOutOrder')}");
            },
            excelAllDetail: function(){
                //导出Excel
                wk.excelAll('',$('.layui-input').serialize(),"{:url('excelOutDetail')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                , data = checkStatus.data;
            $.each(data, function (index, item) {
                ids.push(item['n_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>